<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>角色信息编辑</title>
</head>
<link rel="stylesheet" type="text/css" href="/wms/js/plugins/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/wms/js/plugins/jquery-easyui/themes/icon.css">
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/wms/js/common/common.js"></script>
<script type="text/javascript">
$(function() {
	$("#editForm").submit(function() {
		var validate = $("#editForm").form('validate');
		if (!validate) {
			return false;
		}
		$("#rightSelect option").prop("selected", true);
		$("#mrightSelect option").prop("selected", true);
	});
});

/*校验规则*/
$(function() {
	$(":input[name='role.name']").textbox({
		required:true,
		missingMessage:'名称必填'
	});
	$(":input[name='role.sn']").textbox({
		required:true,
		missingMessage:'编码必填'
	});
});

function mmove() {
	if ("-->" == this.text) {
		var options = $("#mleftSelect option:selected");
		$("#mrightSelect").append(options);
	} else {
		var options = $("#mrightSelect option:selected");
		$("#mleftSelect").append(options);
	}

}

function mmoveAll() {
	if ("==>" == this.text) {
		var options = $("#mleftSelect option");
		$("#mrightSelect").append(options);
	} else {
		var options = $("#mrightSelect option");
		$("#mleftSelect").append(options);
	}
}
</script>
<body>
	<s:if test="hasActionErrors()">
		<script type="text/javascript">
			$.messager.alert('操作提示', '<s:property value="actionErrors[0]"/>', 'error');
		</script>
	</s:if>
	<form id="editForm" method="POST" action="/wms/role_saveOrUpdate.action">
		<s:hidden name="role.id"/>
		<table style="table-layout:fixed;">
			<tr>
				<td width="70px">角色名称</td>
				<td><s:textfield name="role.name"/></td>
			</tr>
			<tr>
				<td>角色编码</td>
				<td><s:textfield name="role.sn"/></td>
			</tr>
		</table>
		<table>
			<tr>
				<td align="center" colspan="3">权限分配</td>
			</tr>
			<tr>
				<td>
					<s:select id="leftSelect" list="#permissions" listKey="id" listValue="name" multiple="true"
					style="width: 180px; height: 225px"></s:select></td>
				<td align="center" style="width: 10px">
				<a class="easyui-linkbutton" data-options="text:'-->',onClick:move"></a><br /> 
				<a class="easyui-linkbutton" data-options="text:'==>',onClick:moveAll"></a><br />
				<a class="easyui-linkbutton" data-options="text:'<--',onClick:move"></a><br />
				<a class="easyui-linkbutton" data-options="text:'<==',onClick:moveAll"></a><br /></td>
				<td>
					<s:select id="rightSelect" list="role.permissions" listKey="id" listValueKey="name" name="role.permissions.id" data-url="/wms/role_roleRoles.action" multiple="true"
					style="width: 180px; height: 225px"></s:select>
				</td>
			</tr>
			<tr>
				<td>
					<s:select id="mleftSelect" list="#systemMenus" listKey="id" listValue="name" multiple="true"
					style="width: 180px; height: 225px"></s:select></td>
				<td align="center" style="width: 10px">
				<a class="easyui-linkbutton" data-options="text:'-->',onClick:mmove"></a><br /> 
				<a class="easyui-linkbutton" data-options="text:'==>',onClick:mmoveAll"></a><br />
				<a class="easyui-linkbutton" data-options="text:'<--',onClick:mmove"></a><br />
				<a class="easyui-linkbutton" data-options="text:'<==',onClick:mmoveAll"></a><br /></td>
				<td>
					<s:select id="mrightSelect" list="role.menus" listKey="id" listValueKey="name" name="role.menus.id" data-url="/wms/role_roleRoles.action" multiple="true"
					style="width: 180px; height: 225px"></s:select>
				</td>
			</tr>
			<tr>
				<td>
					<a class="easyui-linkbutton" data-options="text:'保存',iconCls:'icon-ok',onClick:saveOrUpdate"></a>
					<a class="easyui-linkbutton" data-options="text:'取消',iconCls:'icon-cancel',onClick:cancel"></a>
				</td>
			</tr>
		</table>
		
	</form>

</body>
</html>
